package com.smsc.headend.connector.service;

import com.smsc.headend.connector.bo.ConnectTaskResultDto;
import com.smsc.headend.connector.bo.ConnectionInfo;
import com.smsc.headend.module.asset.entity.ComEntity;
import com.smsc.headend.module.protocol.ProtocolType;
import com.smsc.headend.module.task.dto.ConnectorTask;
import io.netty.channel.Channel;

public interface DeviceConnectService {

    void sendToDevice(ConnectorTask connectorTask);

    void sendByProtocol(ProtocolType protocol, ConnectorTask connectorTask, Channel channel);

    byte[] clientAccept(Channel channel, byte[] bytes);

    /**
     * Netty Server mode accept
     * @param netAddress
     * @param result
     * @return
     */
    void dlmsPacketAccept(Channel netAddress, byte[] result);

    /**
     * 发送报文至netty channel
     * @param channel
     * @param packet
     */
    void sendPacket2Channel(Channel channel, byte[] packet);

    byte[] deviceChannelEstablish(Channel channel, byte[] result);

    void doDeviceRegisterToSystem(Channel channel, byte[] result, String logicAddr);

    /**
     * direct send to device if channel exist
     * @param terminalId
     * @param hexStringToByte
     */
    void sendPacketDirect(ComEntity terminalId, byte[] hexStringToByte);


    ThreadLocal<ConnectionInfo> getConnectionInfoThreadLocal();

    void deviceDisconnect(Channel channel);


    void sendDeviceResultMessage(ConnectTaskResultDto connectTaskResultDto, ComEntity comEntity);

    void ansiPacketAccept(Channel channel, byte[] result);

    void unlockComEntity(Channel channel);

    void sendNotificationToUTE(String pduXml, Channel channel, String deviceAddress);

    int lazySignIn(Channel channel);
}
